package com.droowa.model.service;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.droowa.domain.MyShop;
import com.droowa.domain.PaymentManagement;
import com.droowa.model.dao.MyShopDAO;

@Service
public class MyShopServiceImpl implements MyShopService {

	@Autowired
	private MyShopDAO dao;
	
	@Override
	public int joinMyShop(MyShop myShop) throws SQLException {
		if(getMyShop()!=null){//테이블에 값이 없을 시
			int update = modifyMyShop(myShop);//수정
			if(update==1){
				return -1;//업데이트
			}else{
				return 0;//실패
			}
		}
		return dao.insertMyShop(myShop);//가입
	}
	
	@Override
	public int modifyMyShop(MyShop myShop) throws SQLException {
		return dao.updateMyShop(myShop);
	}
	
	@Override
	public int removeMyShopById(String id) throws SQLException {
		return dao.deleteMyShopById(id);
	}
	
	@Override
	public MyShop getMyShop() throws SQLException {
		return dao.selectMyShop();
	}
	
}